From b97d0a394072cc71f031b80364d659dbf600e8d9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 20 Apr 2021 13:23:56 -0400 Subject: [PATCH] a11y: Avoid spurious selection changed events Only send selection-changed events when we either had a non-empty selection before, or have one now. This should help orca speak the right things, and not the wrong things. Related: #3549 --- gtk/a11y/gtkatspitext.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gtk/a11y/gtkatspitext.c b/gtk/a11y/gtkatspitext.c index 7cf08fdf06..44a5605716 100644 --- a/gtk/a11y/gtkatspitext.c +++ b/gtk/a11y/gtkatspitext.c @@ -1326,9 +1326,12 @@ update_selection (TextChanged *changed, int selection_bound) { gboolean caret_moved, bound_moved; + gboolean had_selection, has_selection; caret_moved = cursor_position != changed->cursor_position; bound_moved = selection_bound != changed->selection_bound; + had_selection = changed->cursor_position != changed->selection_bound; + has_selection = cursor_position != selection_bound; if (!caret_moved && !bound_moved) return; @@ -1339,7 +1342,7 @@ update_selection (TextChanged *changed, if (caret_moved) changed->selection_changed (changed->data, "text-caret-moved", changed->cursor_position); - if (caret_moved || bound_moved) + if (had_selection || has_selection) changed->selection_changed (changed->data, "text-selection-changed", 0); } -- 2.30.2